package br.com.caelum.vraptor.controller;

import java.util.List;

import javax.inject.Inject;

import br.com.caelum.vraptor.Controller;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.auth_annotations.Administrador;
import br.com.caelum.vraptor.auth_annotations.Recepcionista;
import br.com.caelum.vraptor.auth_annotations.Restrito;
import br.com.caelum.vraptor.dao.ClienteDAO;
import br.com.caelum.vraptor.dao.GenericDAO;
import br.com.caelum.vraptor.entidades.Cliente;

@Controller
public class ClienteController {
	
	@Inject
	private Result result;
	
	@Inject
	private GenericDAO<Cliente> dao;
	
	public void add(){
		
	}
	
	public List<Cliente> list(){
		
		return dao.find();
		
	}
	
	public void save(Cliente cliente){
		
		dao.save(cliente);
		
		result.redirectTo(this).list();
	}
	
	public Cliente edit(Integer codCliente){
		return dao.find(codCliente);
	}
	
	public void delete(int codCliente){
		Cliente cliente = new Cliente();
		cliente.setCodCliente(codCliente);
		dao.delete(cliente);
		result.redirectTo(this).list();
	}
	
}
